package cn.shiro.shiroservice.common.utils;

import lombok.Data;

import java.sql.ResultSet;

/**
 * &#064;Time 2024 一月 星期一 16:08
 *
 * @author ShangGuan
 */
@Data
public class R<T> {

    private Integer code;

    private String msg;

    private T data;

    public R(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public R(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> R<T> ok(T data) {
        return new R(200, "操作成功", data);
    }

    public static <T> R<T> ok(Integer code, String msg, T data) {
        return new R(code, msg, data);
    }

    public static <T> R<T> fail(String msg) {
        return new R(400, msg);
    }

    public static <T> R<T> fail(Integer code, String msg) {
        return new R(code, msg);
    }
}
